package cn.wolfcode.producer_test.api._02_send_mode;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

public class Producer {
    public static void main(String[] args) throws Exception {
        //创建一个生产者
        DefaultMQProducer defaultMQProducer = new DefaultMQProducer("wolfcode-producer");
        //绑定namesrv的地址
        defaultMQProducer.setNamesrvAddr("127.0.0.1:9876");
        //启动生产者
        defaultMQProducer.start();
        for (int i = 0; i < 100; i++) {
            //创建一个消息
            Message message = new Message("_02_send_mode","Synchronize Send".getBytes());
            //生产者发送消息
            defaultMQProducer.send(message);
        }
        //关闭资源
        defaultMQProducer.shutdown();
    }
}
